<?php

include_once "boot.php";

echo '<pre>';

$maintable = 'employees';
// Test 1
$keyvalues[0] = array('employeeNumber'=> 1628);
$newvalues[0]['firstName'] = 'NewName';
$newvalues[0]['lastName'] = 'NewLastName';

$result = CF_CrudLibPdo::CrudSave($keyvalues, $newvalues, $maintable);
print 'Test 1';
print_r($result);

// TEST 2
$keyvalues[0]['employeeNumber']=1628;
$newvalues[0]['firstName'] = 'NewName0';
$newvalues[0]['lastName'] = 'NewLastName0';

$keyvalues[1]['employeeNumber']=1629;
$newvalues[1]['firstName'] = 'NewName1';
$newvalues[1]['lastName'] = 'NewLastName1';

$keyvalues[2]['employeeNumber']=1630;
$newvalues[2]['firstName'] = 'NewName2';
$newvalues[2]['lastName'] = 'NewLastName2';

$result = CF_CrudLibPdo::CrudSave($keyvalues, $newvalues, $maintable);
print 'Test 2';
print_r($result);


$result = CF_CrudLibPdo::CrudSave($keyvalues, $newvalues, $maintable);
print 'Test 2';
print_r($result);

$keyvalues[0]['employeeNumber']=1628;
$newvalues[0]['firstName'] = 'OldName';
$newvalues[0]['lastName'] = 'OldLastName';

$result = CF_CrudLibPdo::CrudSave($keyvalues, $newvalues, $maintable);
print 'UnTest 1';
print_r($result);

$keyvalues[0]['employeeNumber']=1628;
$newvalues[0]['firstName'] = 'OldName0';
$newvalues[0]['lastName'] = 'OldLastName0';

$keyvalues[1]['employeeNumber']=1629;
$newvalues[1]['firstName'] = 'OldName1';
$newvalues[1]['lastName'] = 'OldLastName1';

$keyvalues[2]['employeeNumber']=1630;
$newvalues[2]['firstName'] = 'OldName2';
$newvalues[2]['lastName'] = 'OldLastName2';
$result = CF_CrudLibPdo::CrudSave($keyvalues, $newvalues, $maintable);
print 'UnTest 2';
print_r($result);


unset($newvalues);

$newvalues[0]['firstName'] = 'AddedName1';
$newvalues[0]['lastName'] = 'AddedLastName1';
$result = CF_CrudLibPdo::CrudAdd('employeeNumber', $newvalues, $maintable);
print 'ADD test 1';
print_r($result);


// DELETE Test

unset($keyvalues);

//$keyvalues[0]['employeeNumber']=1632;
//$keyvalues[1]['employeeNumber']=1633;
//$keyvalues[2]['employeeNumber']=1634;
//$result = CF_CrudLibPdo::CrudDelete($keyvalues, $maintable);
//print 'DELETE test 1';
//print_r($result);

unset($keyvalues);

$keyvalues[0]['employeeNumber']=$result['keys'][0]['employeeNumber'];
$result = CF_CrudLibPdo::CrudDelete($keyvalues, $maintable);
print 'DELETE test 1';
print_r($result);


echo '</pre>';
?>